define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
    require("$UI/system/lib/cordova/cordova");                
    require("cordova!cordova-plugin-camera");
<<<<<<< HEAD
    require("css!../misc/layui/css/layui").load();
	require("../misc/layui/layui");
	require("../misc/js/when");
	var Model = function(){
		this.callParent();
	};
	Model.prototype.modelModelConstruct = function(event){
      $('.name').html(window.name);
      zuoti = this.comp("ziliao");
         zuoti.clear();
         $.ajax({
               type: "GET",
               url: window.yuming+'/expertinfos/AppGet?login-token='+window.token,     
               async: false,
               cache: false,
               success: function(datas){
                     // var obj = JSON.parse(datas);  
                     // console.log(datas)
                         var zhengzifu=datas.expertCertificate;
                         zhengzifu = zhengzifu.substring(1,zhengzifu.length-1);
                         var ss = zhengzifu.split(",");
                         if(ss[0] != ""){
                             $('.meiimg').css("display","none");       
                              $('.imghe').css("display","block");
                          }
                         if(ss[1] != ""){
                             $('.meiimg2').css("display","none");       
                              $('.imghe2').css("display","block");
                          }
                         if(ss[2] != ""){
                             $('.meiimg3').css("display","none");       
                              $('.imghe3').css("display","block");
                          }
                         if(ss[3] != ""){
                             $('.meiimg4').css("display","none");       
                              $('.imghe4').css("display","block");
                          }
                        //   alert(ss[0].substring(1,ss[0].length-1))
                            var zuotis = 
                            {
                                defaultValues : 
                                [
                                       {
                                        "ziliaoid":datas.id,
                                        "education":datas.education,
								        //蒙文学历
								        "educationMeng":datas.educationMeng,
								        //汉语个人介绍
								        "personal":datas.personal,
								        //蒙文个人介绍
								        "personalMeng":datas.personalMeng,
								        //汉语专长
								        "expertise":datas.expertise,
								        //蒙文专长
								        "expertiseMeng":datas.expertiseMeng,
								        //汉语地区
								        "address":datas.address,
								        //蒙文地区
								        "addressMeng":datas.addressMeng,
								        //性别
								        "sex":datas.sex,
								        //头像图片
								        "headerUrl":window.imgshou+datas.headerUrl,
								        //身份证号
								        "cardNumber":datas.cardNumber,
								        //汉语名
								        "name":datas.name,
								        //蒙文名
								        "nameMeng":datas.nameMeng,
								        "status":datas.status,
								        "shenzheng":window.imgshou+ss[0].substring(1,ss[0].length-1),
								        "shenfan":window.imgshou+ss[1].substring(1,ss[1].length-1),
								        "xueli":window.imgshou+ss[2].substring(1,ss[2].length-1),
								        "zizhi":window.imgshou+ss[3].substring(1,ss[3].length-1),
                                       }
                               ]
                            };
                            zuoti.newData(zuotis);
                    
               
       
               }
        })
      
=======
	var Model = function(){
		this.callParent();
	};

	/*Model.prototype.row4Click = function(event){
         justep.Shell.showPage("login");
	};

	Model.prototype.row6Click = function(event){
	   
        justep.Shell.showPage("register");
	};
*/
	Model.prototype.modelModelConstruct = function(event){
      $('.name').html(window.name);
>>>>>>> db50113a5feef0605bbbc3a649d7e9809a12c455
     
	};
	Model.prototype.row4Click = function(event){
      $('.xm').css("border-right","2px solid #2fa4e7");
      $('.xh').css("border-right","0px solid #2fa4e7"); 
      $('.xhz').css("border-right","0px solid #2fa4e7");
      $('.mxc').css("display","block");
      $('.hxc').css("display","none");
      $('.hxcz').css("display","none");
	};
	Model.prototype.row5Click = function(event){
	  $('.xm').css("border-right","0px solid #2fa4e7");
      $('.xh').css("border-right","2px solid #2fa4e7");
      $('.xhz').css("border-right","0px solid #2fa4e7");
      $('.mxc').css("display","none");
      $('.hxc').css("display","block");
      $('.hxcz').css("display","none");
	};
	Model.prototype.row44Click = function(event){
	  $('.xm').css("border-right","0px solid #2fa4e7");
      $('.xh').css("border-right","0px solid #2fa4e7");
      $('.xhz').css("border-right","2px solid #2fa4e7");
      $('.mxc').css("display","none");
      $('.hxc').css("display","none");
      $('.hxcz').css("display","block");
	};
	Model.prototype.imgbtnClick = function(event) {
<<<<<<< HEAD

    }
 
=======
                if(!navigator.camera){
                        return;
                }
                var self = this;                                
                navigator.camera.getPicture(onLoadImageSuccess, onLoadImageFail, {
                        destinationType:navigator.camera.DestinationType.DATA_URL,
                        allowEdit:true,
                        quality:80,
                        targetWidth:100,
                        targetHeight:100,
                        saveToPhotoAlbum:true
                });
                
                //拍照成功后回调
                function onLoadImageSuccess(imageData){
                        localStorage.setItem("imageData","data:image/jpeg;base64,"+imageData);
                        var smallImage = document.getElementById(self.getIDByXID('image1'));
                        //显示图像
                        smallImage.style.display = 'block';
                        smallImage.src = "data:image/jpeg;base64,"+imageData;                        
                        //图片上传
                        self.uploadPic(imageData);            
                }

                function onLoadImageFail(error){
                        alert(error);
                }
    }
      //调用bass实现图片上传                
        Model.prototype.uploadPic = function(imageData){
        
                //用户信息，用于上传图片后保存图片链接fImage
                var userid = this._UserID;    //this._UserID是自己定义的变量，在页面打开时被初始化
                var userBaasData = this.comp("userBaasData");
                var storeFileName =  "";
                var imageJson = {};

                storeFileName = justep.UUID.createUUID();                            
                
                justep.Baas.sendRequest({
                "url" : window.yuming+"/files?login-token="+window.token,  //baas目录，请根据自己的配置进行修改
                "action" : "uploadPicfile",
                "async" : false,
                "params" : {
                        "picData" : imageData,
                        "ownerID" : userid,
                        "storeFileName" : storeFileName
                },
                "success" : function(data) {

                        justep.Util.hint("图片上传成功");

                        //修改数据库中的图片链接     这里我的字段名叫fImage，可以根据自己的字段名修改                
                        userBaasData.setFilter("Idfilter", "fID='"+userid+"'");
                        userBaasData.refreshData();        
                        if(userBaasData.getCount()>0){
                                var fImage = '{"ownerID":"'+userid+'","storeFileName":"'+storeFileName+'"}';

                                userBaasData.setValue("fImage", fImage);
                                userBaasData.saveData();
                        }                
                }
            });

        };        
   
>>>>>>> db50113a5feef0605bbbc3a649d7e9809a12c455
    
      
	Model.prototype.li1Click = function(event){
	  
     var row=event.bindingContext.$object;
       this.comp("wdEmptym").open({
        params:{
              rowdata:row.toJson()
        }     
       });
	};
	Model.prototype.li2Click = function(event){
       var row=event.bindingContext.$object;
       this.comp("wdEmptyh").open({
        params:{
              rowdata:row.toJson()
        }     
       });
	};
	
<<<<<<< HEAD
	Model.prototype.xxddClick = function(event){
      /*var file=this.comp('shenzheng').uploader;
      console.log(file);
      alert(file)*/
    //  var 
      
	};
	
	Model.prototype.OKbtnClick = function(event){
       var ziliao=this.comp("ziliao").getLastRow().toJson();
         //创建数组，投放证件图片路径
        // var yyy=new Array()
        var id=ziliao.ziliaoid.value;
        //汉语学历
        var education=ziliao.education.value;
        //蒙文学历
        var educationMeng=ziliao.educationMeng.value;
        //汉语个人介绍
        var personal=ziliao.personal.value;
        //蒙文个人介绍
        var personalMeng=ziliao.personalMeng.value;
        //汉语专长
        var expertise=ziliao.expertise.value;
        //蒙文专长
        var expertiseMeng=ziliao.expertiseMeng.value;
        //汉语地区
        var address=ziliao.address.value;
        //蒙文地区
        var addressMeng=ziliao.addressMeng.value;
        //性别
        var sex=ziliao.sex.value;
       // var sexMeng=ziliao.sexMeng;
        //头像图片
        var headerUrl=$('.headimghidden').val();
        //身份证号
        var cardNumber=ziliao.cardNumber.value;
        //汉语名
        var name=ziliao.name.value;
        //蒙文名
        var nameMeng=ziliao.nameMeng.value;
        
        var shenzheng=$('.shenzhengin').val();
        
        var shenfan=$('.shenzhengin2').val();
        
        var xueli=$('.shenzhengin3').val();
        
        var zizhi=$('.shenzhengin4').val();
   
        //  console.log(yaodian.rows);
          
       
        if(ziliao.status.value==2){
           //修改数据
           var data={expertCertificate:'["'+shenzheng+'","'+shenfan+'","'+xueli+'","'+zizhi+'"]',id:id,education: education,educationMeng: educationMeng,personal: personal,personalMeng: personalMeng,expertise: expertise,expertiseMeng: expertiseMeng,address: address,addressMeng:addressMeng,sex:sex,headerUrl:headerUrl,cardNumber:cardNumber,name:name,nameMeng:nameMeng};
           var url=window.yuming+'/expertinfos/AppUpdate?login-token='+window.token;
         }else{
           //新增数据
           var data={expertCertificate:'["'+shenzheng+'","'+shenfan+'","'+xueli+'","'+zizhi+'"]',education: education,educationMeng: educationMeng,personal: personal,personalMeng: personalMeng,expertise: expertise,expertiseMeng: expertiseMeng,address: address,addressMeng:addressMeng,sex:sex,headerUrl:headerUrl,cardNumber:cardNumber,name:name,nameMeng:nameMeng};
           var url=window.yuming+'/expertinfos/AppPut?login-token='+window.token;
        }
        $.ajax({
                type: "POST",
                url: url,     
		        async: false,
		        cache: false,
		        dataType: 'text',
		        data:data,
		        success: function(datas){
		             alert('修改成功，等待审核！');
                     // this.close();
                 },
                 error: function(XMLHttpRequest, textStatus, errorThrown){
                       alert('添加失败！');
                       /* alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);*/
                   //  var code=$.parseJSON(XMLHttpRequest.responseText);        
                     
         
                 }
                 });
        
       
	};
	
=======
>>>>>>> db50113a5feef0605bbbc3a649d7e9809a12c455
	return Model;
});